﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Diagnostics;
using Telerik.Windows;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Controls;
using HeThongThongTin.Library;
using Converter;
using System.Resources;
using System.Reflection;


namespace HeThongThongTin.UI.SL.HeThong.HT_DangKy
{
    public partial class HT_DangKy_MainWindow : UserControl, Csla.Xaml.ISupportNavigation
    {

        #region ISupportNavigation Members
        List<Control> controls = new List<Control>();
        public bool CreateBookmarkAfterLoadCompleted
        {
            get { return true; }
        }

        public event EventHandler LoadCompleted;

        protected virtual void OnLoadCompleted()
        {
            if (LoadCompleted != null)
                LoadCompleted(this, EventArgs.Empty);
        }

        public void SetParameters(string parameters)
        {
            // no parameters
        }

        public string Title
        {
            get { return "QuocGia"; }
        }

        #endregion

        #region Load Methods
        public HT_DangKy_MainWindow()
        {
            LocalizationConverter converter = new LocalizationConverter();
            converter.LocalResourceManager = new ResourceManager("HeThongThongTin.UI.SL.HeThong.HT_DangKy.Resources", Assembly.GetExecutingAssembly());
            this.Resources.Add("Localization", converter);
            InitializeComponent();
            ControlBehavior.ControlBehaviors.Navigation(this.HT_DangKy_GeneralInformation_GroupBox, controls);
            
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                
                
                System.Windows.Data.CollectionViewSource ht_NguoiDung_ViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["HT_NguoiDung_ViewModelSource"];
                HT_NguoiDung_ViewModel ht_NguoiDung_ViewModel = new HT_NguoiDung_ViewModel(BusinessConfiguration.Configuration.DangKyMode);
                ht_NguoiDung_ViewSource.Source = new List<object> { ht_NguoiDung_ViewModel };
                //ht_NguoiDung_ViewModel.Saved += new EventHandler(ht_NguoiDung_ViewModel_Saved);

              
            }
        }       
        #endregion

        private void ComboBox_KeyUp(object sender, KeyEventArgs e)
        {
            ControlBehavior.ComboBoxBehaviors.ComboBox_KeyUp(sender, e, controls);
        }

        private void Control_KeyUp(object sender, KeyEventArgs e)
        {

            ControlBehavior.ControlBehaviors.Control_KeyUp(sender, e, controls);
        }


        #region View Model Related Methods

        void HT_DangKy_ViewModel_Saved(object sender, EventArgs e)
        {
            //System.Windows.Data.CollectionViewSource HT_DangKy_ListViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["HT_DangKy_ListViewModelSource"];
            //HT_DangKy_ListViewModel vm = ((List<object>)HT_DangKy_ListViewSource.Source)[0] as HT_DangKy_ListViewModel;
            //vm.GetHT_DangKy_ListViewModel(BusinessConfiguration.Configuration.GridViewFetchMode);
            
        }

       
        #endregion

        private void HT_DangKy_GeneralInformation_ReMatKhau_PasswordBox_LostFocus(object sender, RoutedEventArgs e)
        {
           
            if (!this.HT_DangKy_GeneralInformation_MatKhau_PasswordBox.Password.Equals(this.HT_DangKy_GeneralInformation_ReMatKhau_PasswordBox.Password))
            {
                MessageBox.Show("Mật khẩu nhập lại chưa chính xác");
            }
            
        }

    }
}
